<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>详情</title>
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"
    />
    <link href="../../../../css/mui.min.css" rel="stylesheet" />
    <link href="../../css/common.css" rel="stylesheet" />
    <link href="../../css/helper.css" rel="stylesheet" />
    <style>
      .mui-content {
        padding-top: 61px !important;
        padding-left: 13px;
        padding-right: 13px;
        margin-bottom: 15px;
      }
      .mui-content p {
        text-align: justify;
      }

      .file-pre-box {
        height: 443px;
        background: #f5f6f7;
        border: 1px solid #034880;
      }

      .file-pre {
        height: 443px;
        padding-left: 20px;
        padding-right: 20px;
        background: #f5f6f7;
        border: 1px solid #034880;
      }

      .img-tool-box {
        height: inherit;
        min-width: 33px;
      }

      .img-tool {
        width: 19px;
        height: 19px;
        margin-top: 10px;
      }
    </style>
  </head>

  <body>
    <div id="container" v-cloak>
      <header class="mui-bar mui-bar-nav">
        <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
        <h1 class="mui-title">详情</h1>
        <a class="mui-pull-right mui-bar-right" v-if="!store">
          <span @click="addStore()">
            <img src="../../img/shoucang_yishoucang.png" class="img-tool" style="margin-left: 13px" v-if="detils.isCollection"/>
            <img src="../../img/shoucang_moren.png" class="img-tool" style="margin-left: 13px" v-else/>
          </span>
          <span @click="downlonds()">
          	<img src="../../img/xiazai.png" class="img-tool" style="margin-left: 13px" v-if="isDown"/>
          	<img src="../../img/xiazai1.png" class="img-tool" style="margin-left: 13px" v-else/>
          </span>
          
          
        </a>
      </header>
      <div class="mui-content">
        <h4 style="text-align: center">{{detils.title}}</h4>
        <p v-html="detils.content"></p>
        <!-- <div class="file-pre">
          <h4 style="text-align: center">文件名称占位文件名</h4>
          <hr>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipis
            cing Aenean euismod bibendum laoreet. Proin 
            gravida doamet lacus accumsan et viverra justo 
            commodo. Prsodales pulvinar sic tempor. Sociis 
            natoque penatibmagnis dis parturient montes, n
            ascetur ridiculus mufermentum, nulla luctus pha
            retra vulputate, felis tellmollis orci, sed rhoncus 
            pronin sapien nunc accuan .
          </p>
        </div> -->
      </div>
    </div>
    <script type="text/javascript" src="../../../../js/mui.js"></script>
    <script
      type="text/javascript"
      src="../../../../js/jquery-3.2.1.min.js"
    ></script>
    <script src="../../../../js/vue.js"></script>
    <script src="../../js/mkeyplus.base.js"></script>
      <script src="../../js/sqlite.js"></script>
    <script type="text/javascript">
      mui.init()
      var ids = 4
      if (window.plus) {
        plusready()
      } else {
        document.addEventListener("plusready", plusready, false)
      }

      function plusready() {
        var self = plus.webview.currentWebview()
        console.log(self.ids)
        ids = self.ids
        vm.ids = self.ids
        console.log("12啊啊啊ww", ids)
        // vm.getDetils()
        
        if(!self.store) {
          vm.getDetils(vm.ids)
          vm.store = false 
        }
        let tech = [{
          key: "id",
          value: vm.ids,
        }]
        mui.DB.selectTableData("technology", tech)
          .then((res) => {
            if(res.length) {
              vm.isDown = true
              if(self.store) {
                vm.detils = res[0]
              }
            } else {
              vm.isDown = false
            }
            console.log(vm.isDown)
          })
          .catch((error) => {
            console.log(error)
          })
      }
      let vm = new Vue({
        el: "#container",
        data: {
          form: {
            page: 1,
            size: 20,
            system: "APP",
            status: 1,
          },
          ids: "",
          detils: {},
          isDown: false,
          store: true //是否从下载进入
        },
        created: function () {},
        mounted() {
        },
        methods: {
          getDetils(ids) {
            let than = this
            console.log("12啊啊啊", ids)
            mui.baseApp.httpRequst(
              "post",
              "/app/api/knowledge/experience/detail/" + ids,
              {},
              function (data) {
                console.log("12", data.data)
                data.data.content = data.data.content ? data.data.content.replace(/\<img /gi,  '<img style="max-width: 100%;" ' ) : '';
                than.detils = data.data
                
                // plus.nativeUI.closeWaiting();
              },
              function () {
                // plus.nativeUI.closeWaiting()
                console.log("获取数据失败1")
              }
            )
          },
          addStore() {
            console.log("2222222")
            mui.baseApp.httpRequst(
              "post",
              "/app/api/knowledge/collection/add",
              {
                tagetId: this.detils.id,
                type: 3,
              },
              (data) => {
                this.detils.isCollection = !this.detils.isCollection
                mui.fire(plus.webview.currentWebview().opener(), 'collection', {id: this.detils.id, isCollection: this.detils.isCollection})
                mui.toast("操作成功")
              }
            )
          },
          downlonds() {
            let des = this.detils
            let parm = {
              id: des.id,
              typeCode: des.typeCode || "",
              title: des.title || "",
              content: des.content || "",
              isShare: des.isShare || "",
              isCollection: des.isCollection || "",
              createId: des.createId || "",
              createName: des.createName || "",
              createTime: des.createTime || "",
              updateTime: des.updateTime || "",
              updateId: des.updateId || "",
              typeCodeName: des.typeCodeName || "",
              isLike: des.isLike || "",
              fileDescribe: des.fileDescribe || "",
              t: des.title || "",
              cn: des.createName || "",
              isTop: des.isTop || "",
              isBest: des.isBest || "",
            }
            mui.DB.addColumn("technology", "isCollection").catch(err => {
              console.log(err)
            })
            mui.DB.createFormat("technology", parm, "id")
            mui.DB.insertOrReplace("technology", parm)
            mui.fire(plus.webview.currentWebview().opener(), 'collection', {id: this.detils.id, isDown: true})
            des.isDown = true
          }
        },
      })
    </script>
  </body>
</html>
